﻿using log4net;
using System;
using System.IO;

namespace LD.Host
{
    public class Log4
    {
        private static readonly ILog _log = LogManager.GetLogger("EventLog");
        private static readonly ILog _ccdLog = LogManager.GetLogger("CCDLog");
        private static readonly ILog _alarmLog = LogManager.GetLogger("AlarmLog");
        private static readonly ILog _hiveLog = LogManager.GetLogger("HiveLog");
        private static readonly ILog _autoLog = LogManager.GetLogger("AutoLog");
        private static readonly ILog _parameChangeLog = LogManager.GetLogger("ParameChangeLog");
        private static readonly ILog _baliLog = LogManager.GetLogger("BaliLog");

        public static void Init()
        {
            FileInfo file = new FileInfo(AppDomain.CurrentDomain.BaseDirectory + "Log4Net.xml");
            log4net.Config.XmlConfigurator.Configure(file);
        }

        public static void Info(string content)
        {
            if (_log.IsInfoEnabled)
            {
                _log.Info(content);
            }
        }
        public static void Warr(string content)
        {
            if (_log.IsWarnEnabled)
            {
                _log.Warn(content);
            }
        }
        public static void Error(string content, Exception ex)
        {
            if (_log.IsErrorEnabled)
            {
                _log.Error(content, ex);
            }
        }
        public static void Error(string content)
        {
            if (_log.IsErrorEnabled)
            {
                _log.Error(content);
            }
        }
        public static void Error(Exception ex)
        {
            if (_log.IsErrorEnabled)
            {
                _log.Error(ex);
            }
        }
        public static void Alarm(string content)
        {
            if (_alarmLog.IsInfoEnabled)
            {
                _alarmLog.Info(content);
            }
        }
        public static void ParamChange(string content)
        {
            if (_parameChangeLog.IsInfoEnabled)
            {
                _parameChangeLog.Info(content);
            }
        }
        public static void Hive(string content)
        {
            if (_hiveLog.IsInfoEnabled)
            {
                _hiveLog.Info(content);
            }
        }
        public static void Bali(string content)
        {
            if (_baliLog.IsInfoEnabled)
            {
                _baliLog.Info(content);
            }
        }
        public static void CCD(string content)
        {
            if (_ccdLog.IsInfoEnabled)
            {
                _ccdLog.Info(content);
            }
        }
        public static void Auto(string content)
        {
            if (_autoLog.IsInfoEnabled)
            {
                _autoLog.Info(content);
            }
        }
    }
}
